#include "gemv.hpp"

GEMVTester::GEMVTester(size_t row, size_t col) {
  _input_matrix = Matrix<int64_t>(row, col);
  _input_vector.resize(col);
}

void GEMVTester::DataGenerate() {
  std::random_device rd;
  std::mt19937 gen(rd());
  std::uniform_int_distribution<int> distrib(0, 1);
  size_t row = _input_matrix.Row();
  size_t col = _input_matrix.Col();
  for (size_t i = 0; i < row; ++i) {
    for (size_t j = 0; j < col; ++j) {
      _input_matrix[i][j] = distrib(gen);
    }
  }
  for (size_t i = 0; i < col; ++i) {
    _input_vector[i] = distrib(gen);
  }
}

bool GEMVTester::CheckResult() {
  if (_baseline_result.size() != _impl_result.size()) {
    return false;
  }
  size_t len = _baseline_result.size();
  bool ret = true;
  for (size_t i = 0; i < len; ++i) {
    if (_baseline_result[i] != _impl_result[i]) {
      ret = false;
      break;
    }
  }
  return ret;
}

